// ignore_for_file: non_constant_identifier_names
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:wallpaper_app/components/list_title/my_list_title.dart';
import 'package:wallpaper_app/components/list_title/my_list_title_model.dart';
import 'package:wallpaper_app/pages/setting/local_image.dart';
import 'package:wallpaper_app/pages/love/love_page.dart';
import 'package:wallpaper_app/pages/setting/cache_clean.dart';
import 'package:wallpaper_app/pages/setting/update_page.dart';
import 'package:wallpaper_app/pages/setting/wallhaven_apikey.dart';
import 'package:wallpaper_app/pages/theme/theme_page.dart';
import 'package:wallpaper_app/themes/theme_provider.dart';

class PersonalCenter extends StatelessWidget {
  const PersonalCenter({super.key});

  @override
  Widget build(BuildContext context) {
    List MyListTitleList = [
      ['我的 wallhaven apiKey', Icons.hdr_auto_outlined, WallhavenApikey()],
      ['本地图片', Icons.local_offer_outlined, LocalImage(title: '本地图片')],
      ['主题', Icons.color_lens_outlined, ThemePage()],
      ['图片收藏', Icons.favorite_outline, LovePage(axis: 'horizontal')],
      ['缓存', Icons.cached, CacheClean()],
      ['关于', Icons.info, UpdatePage()],
    ];
    final theme = Theme.of(context).colorScheme;
    return Scaffold(
      appBar: AppBar(
          backgroundColor: theme.primaryContainer,
          surfaceTintColor: theme.primaryContainer,
          toolbarHeight: 40,
          actions: [
            IconButton(
              onPressed: () {
                Provider.of<ThemeProvider>(context, listen: false)
                    .toggleTheme();
              },
              icon:
                  Provider.of<ThemeProvider>(context, listen: false).isDarkMode
                      ? Icon(
                          Icons.brightness_4,
                          color: theme.inversePrimary,
                        )
                      : Icon(
                          Icons.brightness_7,
                          color: theme.inversePrimary,
                        ),
            ),
            SizedBox(width: 10)
          ]),
      body: ListView(
        children: [
          SizedBox(height: 15),
          Padding(
              padding: const EdgeInsets.all(8.0),
              child: MyListTitle(
                list: [
                  for (int i = 0; i < MyListTitleList.length; i++)
                    MyListTitleModel(
                      title: MyListTitleList[i][0],
                      leading: Icon(MyListTitleList[i][1]),
                      route: MyListTitleList[i][2],
                    )
                ],
              ))
        ],
      ),
    );
  }
}
